//package com.easylinkin.linkappapi.airconditioner.controller;
//
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.easylinkin.linkappapi.airconditioner.entity.AirconditionDevice;
//import com.easylinkin.linkappapi.airconditioner.service.AirconditionDeviceService;
//import com.easylinkin.linkappapi.common.model.RequestModel;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.util.Assert;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.multipart.MultipartFile;
//import site.morn.rest.RestBuilders;
//import site.morn.rest.RestMessage;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.List;
//import java.util.Set;
//
///**
// * @program: linkapp-group
// * @description: 空调子设备
// * @author: chenkaixuan
// * @create: 2021-05-08 14:59
// */
//@RestController
//@RequestMapping("/airconditioner/airChildDevice")
//public class AirconditionDeviceController {
//
//    @Autowired
//    AirconditionDeviceService airconditionDeviceService;
//
//    /***
//     * 分页查询
//     */
//    @PostMapping("getPage")
//    public RestMessage getPage(@RequestBody RequestModel<AirconditionDevice> requestModel){
//        Assert.notNull(requestModel.getCustomQueryParams(), "customQueryParams 不能为空");
//        Assert.notNull(requestModel.getCustomQueryParams().getHostDeviceId(), "hostDeviceId 不能为空");
//        Assert.notNull(requestModel.getPage(), "page 不能为空");
//        return RestBuilders.successBuilder().data(airconditionDeviceService.getPage(requestModel.getPage(),requestModel.getCustomQueryParams())).build();
//    }
//
//    /***
//     * 批量添加
//     * @return
//     */
//    @PostMapping("insertBatch")
//    public RestMessage insertBatch(@RequestBody List<AirconditionDevice> airHostDeviceList){
//        airconditionDeviceService.batchInsert(airHostDeviceList);
//        return RestBuilders.successBuilder().build();
//    }
//
//    /***
//     * 批量添加
//     * @return
//     */
//    @PostMapping("update")
//    public RestMessage update(@RequestBody AirconditionDevice airconditionDevice){
//        airconditionDeviceService.updateDeviceFan(airconditionDevice);
//        return RestBuilders.successBuilder().build();
//    }
//
//    /***
//     * 获取主机下设备
//     * @param airconditionDevice
//     * @return
//     */
//    @PostMapping("getHostLowerDevice")
//    public RestMessage getHostLowerDevice(@RequestBody AirconditionDevice airconditionDevice){
//        return RestBuilders.successBuilder().data(airconditionDeviceService.getHostLowerAirconditionDeviceAll(airconditionDevice)).build();
//    }
//
//    /***
//     * 移除设备
//     * @param airconditionDevice
//     * @return
//     */
//    @PostMapping("removeByIds")
//    public RestMessage removeHostLowerDeviceByIds(@RequestBody AirconditionDevice airconditionDevice){
//        airconditionDeviceService.removeHostLowerAirconditionDeviceById(airconditionDevice);
//        return RestBuilders.successBuilder().build();
//    }
//
//    /***
//     * 下载导入模板
//     * @param request
//     * @param response
//     */
//    @GetMapping("getImportTemplate")
//    public void getImportTemplate(HttpServletRequest request, HttpServletResponse response) {
//        airconditionDeviceService.getImportTemplate(request, response);
//    }
//
//    @PostMapping("importData")
//    public RestMessage importData(@RequestParam(value = "file") MultipartFile file) {
//        Assert.notNull(file, "文件不能为空");
//        Set errors = airconditionDeviceService.importData(file);
//        if(errors.isEmpty()) {
//            return RestBuilders.successBuilder().data("导入成功").build();
//        }else {
//            String errorMsg = "";
//            for(Object obj : errors) {
//                errorMsg = errorMsg +"第" + obj.toString() + "行  ";
//            }
//            errorMsg = errorMsg + "数据错误,请核对后再提交。";
//            return RestBuilders.successBuilder().data(errorMsg).build();
//        }
//    }
//}
